<template>
  <div class="app-container">
    <div class="content">
      <el-form @submit.native.prevent ref="userRef" label-width="120px">
        <el-row v-for="(item, index) in typeList" :key="index" :gutter="20">
          <el-col class="row" :span="10">
            <dict-tag
              class="label"
              :options="contribution_type"
              :value="item.bizType"
            />
            <el-form-item prop="score">
              <el-input
                type="number"
                v-model="item.score"
                placeholder="请输入"
                :min="0"
              />
              <span class="hint">（即发一遍在审核通过后获得多少积分）</span>
            </el-form-item>
          </el-col>
          <el-col :span="10">
            <el-form-item label="每天获得次数：" prop="timesPerDay">
              <el-input
                type="number"
                v-model="item.timesPerDay"
                placeholder="请输入"
                :min="0"
              />
              <span class="hint">（0 为可无限次）</span>
            </el-form-item>
          </el-col>
          <el-col :span="4">
            <el-button type="primary" size="small" @click="submitForm(item)"
              >修改</el-button
            >
          </el-col>
        </el-row>
      </el-form>
    </div>
  </div>
</template>
  
  <script setup name="contribution">
import { queryScorePage, editScore } from "@/api/contribution";
const { proxy } = getCurrentInstance();
const { contribution_type } = proxy.useDict("contribution_type");
const queryParams = ref({
  pageNum: 1,
  pageSize: 1000,
  sourceType: 1,
});
const typeList = ref([]);
const loading = ref(true);
/** 查询列表 */
const getList = () => {
  loading.value = true;
  queryScorePage({
    ...queryParams.value,
  }).then((res) => {
    loading.value = false;
    typeList.value = res.rows;
  });
};

/** 提交按钮 */
const submitForm = (e) => {
  editScore({
    id: e.id,
    score: e.score,
    timesPerDay: e.timesPerDay,
  }).then((response) => {
    proxy.$modal.msgSuccess("编辑成功");
    getList();
  });
};
getList();
</script>
  <style lang='scss' scoped>
.content {
  width: 1000px;
  margin: 50px auto;
}
.row {
  position: relative;
  .label {
    position: absolute;
    left: 20px;
    top: 10px;
  }
}
.footer {
  display: flex;
  justify-content: right;
}
.hint {
  color: #999;
}
</style>
  